﻿using System.Reflection;
using Autofac;
using GarageManagement.ViewModel;

namespace GarageManagement.Startup
{
    public class IocContainer
    {
        public static IContainer Current { get; set; }

        public void Configure()
        {
            var builder = new ContainerBuilder();
            RegisterBootstrapper(builder);
            builder.RegisterAssemblyTypes(Assembly.GetExecutingAssembly());

            Current = builder.Build();
            ViewModelLocator.Container = Current;
        }

        private void RegisterBootstrapper(ContainerBuilder builder)
        {
            builder.RegisterAssemblyTypes(Assembly.GetExecutingAssembly())
                   .Where(t => typeof(BootstrapperStep).IsAssignableFrom(t))
                   .As<BootstrapperStep>();
        }
    }
}
